package cn.sc.allinpay.allfavour.business.common.adapter;

import android.support.v7.widget.AppCompatTextView;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import java.math.BigDecimal;

import cn.pai.common.adapter.BaseRecyAdapter;
import cn.sc.allinpay.allfavour.R;
import cn.sc.allinpay.allfavour.business.common.data.OilListRecord;

/**
 * description：收银台交易流水 适配器
 * author：pany
 * on 2018/7/17 15:02
 */
public class CashierTransOnlineAdapter extends BaseRecyAdapter<CashierTransOnlineAdapter.MyViewHoder, OilListRecord> {

    @Override
    public int layoutId() {
        return R.layout.item_cashier_trans;
    }

    @Override
    public MyViewHoder onCreateViewHolder(View view) {
        return new MyViewHoder(view);
    }

    @Override
    public void onBindViewHolder(MyViewHoder holder, int position, OilListRecord data) {
        holder.tvNumber.setText(String.valueOf((++position)) + ". ");
        holder.tvTransNo.setText(data.getPayNum());
        holder.tvAmt.setText(data.getTotalAmt().divide(new BigDecimal(100),2, BigDecimal.ROUND_DOWN).toString());
        holder.tvTrsTime.setText(data.getPayTime());
        String stateText = null;
        if (data.getOilType().equals("01")) {
            stateText = "92#";
        } else if (data.getOilType().equals("02")) {
            stateText = "95#";
        } else if (data.getOilType().equals("03")) {
            stateText = "98#";
        } else if (data.getOilType().equals("04")) {
            stateText = "0#";
        } else if (data.getOilType().equals("05")) {
            stateText = "CNG";
        } else if (data.getOilType().equals("06")) {
            stateText = "LNG";
        } else if (data.getOilType().equals("07")) {
            stateText = "非油品";
        } else if (data.getOilType().equals("08")) {
            stateText = "其它";
        }
        holder.tvTrsState.setText(stateText);
    }

    class MyViewHoder extends RecyclerView.ViewHolder {

        AppCompatTextView tvNumber;//序号
        AppCompatTextView tvTransNo;//交易流水
        AppCompatTextView tvAmt;//交易金额
        AppCompatTextView tvTrsTime;//交易时间
        AppCompatTextView tvTrsState;//状态


        public MyViewHoder(View itemView) {
            super(itemView);
            // TODO Auto-generated constructor stub
            tvNumber = itemView.findViewById(R.id.tvNumber);
            tvTransNo = itemView.findViewById(R.id.tvTransNo);
            tvAmt = itemView.findViewById(R.id.tvAmt);
            tvTrsTime = itemView.findViewById(R.id.tvTrsTime);
            tvTrsState = itemView.findViewById(R.id.tvTrsState);
        }
    }
}
